#include <stdio.h>
#include <string.h>
#include <stdlib.h>


char* secure(char pwd[100]) {
	// encrypt pwd
	char encrypt_pwd[128] = { '\0' };
	int i;
	int count = strlen(pwd);

	for (i = 0; i < count; i++)
	{
		/* encryption */
		encrypt_pwd[i] = pwd[i] + i + 5;
	}

	encrypt_pwd[i] = '\0';
	char* return_pwd = (char*)malloc(sizeof(char*) * 100);
	strcpy(return_pwd, encrypt_pwd);
	return return_pwd;
}

char* re_secure(char pwd[100]) {
	// decoding msg
	char re_pwd[128] = {'\0'};
	int i;
	int count = strlen(pwd);

	for ( i = 0; i < count; ++i)
	{
		/* decoding */
		re_pwd[i] = pwd[i] - i - 5;
	}

	re_pwd[i] = '\0';
	char* return_pwd = (char*)malloc(sizeof(char*) * 100);
	strcpy(return_pwd, re_pwd);
	return return_pwd;
}

int main(int argc, char const *argv[])
{
	/* code */
	char msg[100] = "I am xxx";
	char se_msg[100];
	char re_msg[100];

	strcpy(se_msg, secure(msg));
	printf("%s\n", se_msg);

	// decoding
	strcpy(re_msg, re_secure(se_msg));
	printf("%s\n", re_msg);


	return 0;
}